home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 22
/
Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso
/
Aminet
/
biz
/
dopus
/
empDopus.lha
/
empDopus_r1.1.lha
/
Source
/
emp_playdt.dopus5
< prev
next >
Wrap
Text File
|
1997-10-20
|
14KB
|
438 lines
/*$VER: emp_PlayDT.dopus5 1.1 (20.10.97) B00ze
* For questions or comments email Booze@Videotron.CA
*
* Mod-Player interface for Directory Opus 5.5 and Delitracker,
* Based on Deliplay (C module).
*
* This version differs with Leo's PlaymodDT in that it builds a modlist
* and passes THAT to Delitracker, so you don't have a "continue" requester
* anymore. It'll also work from any lister, provided you call it from a
* lister toolbar (we always get passed the lister's handle in that case).
*
* This one is also in the form of a MODULE (less overhead), and gives you
* additional commands like "DTStop" and "DTShow" etc... I was forced to
* do this script because DeliPlay, the C module, waits forever before
* it releases the lister (it inserts the files into the playlist 1 at a
* time and has to wait for the damn port because of that, annoying).
*
* If the player's ARexx port is not found, the program will be run for
* you (you MUST provide the path to the Delitracker executable in the
* call to this script) . This means the script may fail if you disable
* the player's ARexx port, or give an incorrect command line to it. If
* the ARexx port takes more than 10 seconds to appear, an error requester
* will appear on the DOpus screen and the script will quit.
*
* USAGE:
*
* All commands but one are called with no parameter; the PLAY command
* needs to be given the Delitracker2 path/execname within dquotes and
* can be passed 1 startup option, whatever else follows is passed on
* to the delitracker executable (WHEN FIRST STARTED only though!):
*
* PlayDT_Play "PathToDelitracker2Exec/ExecName" [Option] [DTStartupOptions]
*
* Examples:
*
* 1- Start Delitracker, no selected files, filter on, and hide the GUI:
*
* PlayDT_Play "WORK:Soundp/Delitracker2" HIDEDT filter=yes
*
* 2- Play the selected tunes, and show the GUI:
*
* PlayDT_Play "WORK:Soundp/Delitracker2" SHOWDT
*
* NOTES
*
* -You can't play directories - but that's easy to change if needed,
*
* -Calling us with no selected files just tries to run Delitracker,
*
* -WHEN STARTED, we give DT Dopus's screename, so it'll popup there.
*
* -There is a "hardwired" "fade" of 1 second for playlists - It is
* in the form of a variable so you can change it below, but you do
* have to do some editing...
*
* -When specifying Delitracker's path/execname, it NEEDS to have a
* path! We need to know its root directory so that it can find its
* subdirectories (so a resident Delitracker won't do).
*
* -Some S3M modules (or some version of the S3M player) do not handle
* the SongEnd event properly; if you play a bunch of these, the
* modlist may "jam" on a certain S3M and keep playing it until
* you force it to move on, it ain't this script's fault.
*
* PROGRAM HISTORY
*
* v1.0 -Made into a MODULE,
* -Changed the lister searches,
* -Sends the list of selected files as a modulelist,
* -More commands and options, even pass startup options to DT!
* -Uses DT.cfg in Dopus/Settings WHEN STARTING DT (copy your own there),
* -Releases the lister almost immediately - hurray!
*
* v1.1 -Improved signal traps.
* -Made a bunch of code into functions.
* -Requesters will be centered on the lister window whenever possible.
* -Amount of FADE for modlists can now be "configured" at the top
* of this script via the variable dtFade.
*
*/
dtConfig='Config=Dopus5:Settings/DT.cfg' /* Only used if WE loadup DT */
dtSettings='Playstart=NO Quickstart=YES CX_Popup=NO Activate=NO' /* Idle start options */
dtFade=1 /* Time to fade the playlists */
PN='PlayDT.dopus5'
SH=0;WIN=0;LF='0A'x /* These are globals needed by almost every function I use! */
Options results
Signal ON SYNTAX
Signal ON BREAK_C
Signal ON FAILURE
Signal ON IOERR
Parse ARG P F SH DH A
Address VALUE P
/* Initialization */
F=Upper(F)
If F='INIT' Then Do
'Dopus Command PlayDT_Play Program emp_playdt Desc "Play Module(s)" Template "DT2Execname/A (Use quotes!),HideDT/S,ShowDT/S,DT2StartupOptions..." SOURCE'
'Dopus Command PlayDT_Stop Program emp_playdt Desc "Stop Playing"'
'Dopus Command PlayDT_Show Program emp_playdt Desc "Show Delitracker"'
'Dopus Command PlayDT_Hide Program emp_playdt Desc "Hide Delitracker"'
'Dopus Command PlayDT_Quit Program emp_playdt Desc "Quit Delitracker"'
'Dopus Command PlayDT_Pause Program emp_playdt Desc "Pause playing"'
'Dopus Command PlayDT_Next Program emp_playdt Desc "Skip to next song"'
'Dopus Command PlayDT_Prev Program emp_playdt Desc "Skip to previous song"'
Exit 0
End
/* MAIN */
Options failat 21
Select
When F='PLAYDT_PLAY' Then Call DTPLAY
When F='PLAYDT_STOP' Then If Show('P',"DELITRACKER") Then Do
Address 'DELITRACKER'
'Fadeout 0'
'Clearlist'
/* Address VALUE P */
End
When F='PLAYDT_SHOW' Then If Show('P',"DELITRACKER") Then Address 'DELITRACKER' 'ShowGUI'
When F='PLAYDT_HIDE' Then If Show('P',"DELITRACKER") Then Address 'DELITRACKER' 'HideGUI'
When F='PLAYDT_QUIT' Then If Show('P',"DELITRACKER") Then Address 'DELITRACKER' 'Quit'
When F='PLAYDT_PAUSE' Then If Show('P',"DELITRACKER") Then Address 'DELITRACKER' 'Playpause'
When F='PLAYDT_NEXT' Then If Show('P',"DELITRACKER") Then Address 'DELITRACKER' 'Nextsong'
When F='PLAYDT_PREV' Then If Show('P',"DELITRACKER") Then Address 'DELITRACKER' 'Prevsong'
Otherwise NOP
End
Exit 0
/*-----------------------------------------------------------
Play/START
-----------------------------------------------------------*/
DTPLAY:
If ~GSL() Then Call ReqERR('No Source Lister To Work With!') /* First, let's see if we got a lister to work with */
dtExec=GARGS() /* Parse execname and other arguments */
Call GFILES()
'Lister Set' SH 'Busy 0' /* We're done with the lister, free the fucker */
If ~RunDT() Then Call ReqERR('Unable to Run/Locate DeliTracker!')
If FL.count=0 Then Exit 0 /* We're done */
Address 'DELITRACKER'
If FL.count=1 Then 'Songend NO'
Else Do
'Songend YES'
'Fadeout 'dtFade
End
Options failat 30;'Playmod 'FN;Options failat 21
If RC~=0 Then Call ReqERR('Delitracker was unable to play the selected file(s).')
Address VALUE P
If FL.count>1 Then 'Command Delete "'FN'" QUIET'
Return(1)
/*-----------------------------------------------------------
GARGS - Parse args for Delitracker path/execname
-----------------------------------------------------------*/
GARGS:
Parse VAR A '"' nam '"' A
nam=Strip(nam,'B')
If nam="" Then Call ReqERR('You MUST pass PLAY the path/name of the Delitracker'LF'executable, within double quotes.')
If ~Exists(nam) Then Call ReqERR('Unable to locate the Delitracker executable:'LF||nam)
tmp=Left(nam,Max(Lastpos(':',nam),(Lastpos('/',nam)))) /* Neat path trick by Timo */
Call Pragma('D',tmp) /* We need this for relative pathnames in DT's config */
/* Now see if we were also passed an arg, and leave what's left to delitracker */
A=Strip(A,'B')
If A~="" Then Do
Parse VAR A tmp A
tmp=Upper(tmp)
If tmp="SHOWDT"|tmp="HIDEDT" Then dtGUI=tmp
Else Do
dtGUI="NA"
A=' 'tmp||A /* Return to Ceasar what is Ceasar's */
End
End
'Dopus Screen'
Parse VAR RESULT S .
Return('RUN <NIL: >NIL: "'nam'" 'dtConfig' Pubscreen="'S'" 'dtSettings||A)
/*-----------------------------------------------------------
RunDT - Run and/or Show/Hide DT
-----------------------------------------------------------*/
RUNDT:
If ~Show('P',"DELITRACKER") Then Do
Address COMMAND dtExec
Address COMMAND 'C:WaitForPort DELITRACKER'
If ~Show('P',P) Then Exit 21 /* Dopus is gone?! */
If ~Show('P',"DELITRACKER") Then Return(0)
End
Address 'DELITRACKER'
Select
When dtGUI="HIDEDT" Then Do
'Status G GUI'
If Upper(RESULT)='YES' Then 'HideGUI'
End
When dtGUI="SHOWDT" Then Do
'Status G GUI'
If Upper(RESULT)='NO' Then 'ShowGUI'
End
Otherwise NOP
End
If FL.count~=0 Then Do
'Fadeout 0'
'Clearlist'
End
Return(1)
/*-----------------------------------------------------------
GFILES - Build the MODLIST
-----------------------------------------------------------*/
GFILES:
FL.=0
'Lister Query' SH 'Numselfiles'
If RESULT=0|RESULT="RESULT" Then Return(1) /* Nothing to play */
LP=GLP(SH) /* Get terminated lister path */
/* Get the array of selected files */
'Lister Query' SH 'Selfiles Stem FL.'
If FL.count=0 Then Call ReqERR('Unable To Obtain List Of Selected Files!') /* We tested for files before, not good */
/* Open the MODLIST file we pass to Delitracker, if more than 1 entry */
If FL.count=1 Then Do
FN=LP||FL.0 /* We'll check later to see if we got more than 1 entry and set the appropriate options */
'Lister Select' SH '"'FL.0'" 0'
End
Else Do
FN='T:PlayDT.'Pragma('ID')'.tmp'
IF ~Open('L',FN,'W') Then Call ReqERR('Unable To Open ModList File!')
/* Save all selected entries in the SH lister to the file and deselect */
Call WriteLN('L','MODLIST')
Do x=0 To FL.count-1
Call WriteLN('L',LP||FL.x)
'Lister Select' SH '"'FL.x'" 0'
End
End
'Lister Refresh' SH
If FL.count>1 Then If ~Close('L') Then Call ReqERR('Unable To Close MODLIST File!')
Return(1)
/*-----------------------------------------------------------
Get Source Lister
You MUST Initialise WIN and SH to Zer0!
-----------------------------------------------------------*/
/* Returns the GLOBALS SH and WIN, the idea being that all requesters
* should appear within the calling window. When SH is already set to
* a non-zero numeric value, we assume we've parsed a valid {Ql} arg.
*
* When SH is zero, we query Dopus for a SOURCE-Lister. If we are
* passed 'D' we try for a DEST-Lister when no SOURCE-Lister can be
* obtained. If we are passed 'A' we try for that when DEST fails. */
GSL: PROCEDURE EXPOSE P LF PN SH WIN /* USAGE: Success=GSL(Scantype) */
If Datatype(SH)~="NUM" Then Call ReqERR('UnInitialized SH/SourceHandle!')
If SH=0 Then Do
Parse UPPER ARG STyp
If STyp~="D"|STyp~="A" Then STyp="S"
SL.=0
'Lister Query Source Stem SL.'
If SL.count=0 Then If STyp="S" Then Return(0)
Else Do
'Lister Query Dest Stem SL.'
If SL.count=0 Then If STyp="D" Then Return(0)
Else Do
'Lister Query ALL Stem SL.'
If SL.count=0 Then Return(0)
End
End
SH=SL.0
End
'Lister Set' SH 'Source'
'Lister Query' SH 'Window'
If RESULT~=0&Datatype(RESULT)='NUM' Then WIN=RESULT
Else WIN=0
Return(1)
/*-----------------------------------------------------------
Get Terminated Lister Path
-----------------------------------------------------------*/
GLP: PROCEDURE EXPOSE P LF PN SH WIN /* USAGE: Path=GLP(ListerHandle) */
Parse ARG LH
'Lister Query' LH 'PATH'
If RESULT=""|RESULT="RESULT" Then Call ReqERR('Unable To Obtain Lister PATH!')
Else Do
LP=RESULT
If Right(LP,1)~=':'&Right(LP,1)~='/' Then LP=LP'/'
End
Return(LP)
/*-----------------------------------------------------------
Requesters
All functions assume the current port to be Dopus's
-----------------------------------------------------------*/
/* All requesters work on the calling lister, specified by the globals
* SH/WIN, when set. To force a lister to appear centered on the dopus
* screen instead, supply the extra switch 'NW' for 'NoWin-Centered' */
ReqERR: PROCEDURE EXPOSE P LF PN SH WIN /* USAGE: GReqERR('requestertext'[,'NW']) - Quits! */
Parse ARG TXT,A
A=Upper(A)
'Command Flash'
If ~Show('L',"rexxreqtools.library") Then CALL AddLib('rexxreqtools.library',0,-30,0) /* Try to get rexxreqtools loaded */
If ~Show('L',"rexxreqtools.library") Then Do
If SH=0|Datatype(SH)~="NUM"|A="NW" Then RCMD='Dopus Request'
Else RCMD='Lister Request 'SH
RCMD' "+++ 'PN' Error +++'LF||TXT'" OK'
End
Else Do
If WIN=0|Datatype(WIN)~="NUM"|A="NW" Then Do
'Dopus Screen'
Parse VAR RESULT S .
RTAG='RT_PubScrName='S' rt_reqpos=reqpos_centerscr'
End
Else RTAG='RT_Window='WIN' rt_reqpos=reqpos_centerwin'
CALL rtEZRequest('+++ 'PN' Error +++'LF||TXT,,PN,RTAG' rtez_flags=ezreqf_centertext rt_idcmpflags=idcmp_vanillakey')
End
If SH~=0 Then Do
'Lister Set' SH 'Busy 0'
'Lister Set' SH 'Title'
'Lister Refresh' SH 'FULL'
End
Exit 20
/*-----------------------------------------------------------
ERROR HANDLERS
-----------------------------------------------------------*/
BREAK_C:
Address VALUE P
If SH~=0 Then Do
'Lister Set' SH 'Busy 0'
'Lister Set' SH 'Title'
'Lister Refresh' SH 'FULL'
RCMD='Lister Request 'SH
End
Else RCMD='Dopus Request'
'Command Flash'
RCMD' "+++ Break! +++" OK'
Call Close('L')
Exit 0
SYNTAX:
RCX=RC
Address VALUE P
If SH~=0 Then Do
'Lister Set' SH 'Busy 0'
'Lister Set' SH 'Title'
'Lister Refresh' SH 'FULL'
RCMD='Lister Request 'SH
End
Else RCMD='Dopus Request'
'Command Flash'
RCMD' "+++ Syntax Error +++'LF'('RCX') at line 'SIGL||LF||errortext(RCX)'" OK'
Call Close('L')
Exit 20
FAILURE:
Address VALUE P
If SH~=0 Then Do
'Lister Set' SH 'Busy 0'
'Lister Set' SH 'Title'
'Lister Refresh' SH 'FULL'
RCMD='Lister Request 'SH
End
Else RCMD='Dopus Request'
'Command Flash'
RCMD' "+++ Failure +++'LF'Something failed at line 'SIGL'" OK'
Call Close('L')
Exit 20
IOERR:
Address VALUE P
If SH~=0 Then Do
'Lister Set' SH 'Busy 0'
'Lister Set' SH 'Title'
'Lister Refresh' SH 'FULL'
RCMD='Lister Request 'SH
End
Else RCMD='Dopus Request'
'Command Flash'
RCMD' "+++ I/O Error +++'LF'I/O Operation failed at line 'SIGL'" OK'
Call Close('L')
Exit 20